﻿define(["global", "synxBindingHandlers", "bokeh"], function (global, synx, bokeh) {

    var model =ko.mapping.fromJS({
      Name :"John"  ,
      Surname :"Doh"  ,
      Street :"Westblock"  ,
      Housenumber: "3",
      PostalCode: "88376",
      City: "Zwolle",
    });

    model.chatList = synx.allChatMessages;
    ko.applyBindings(model, $("#ko-content")[0]);

    bokeh.bokehBoard("body", function (target, top, left, size, r, g, b) {
        synx.sendBokeh(target, top, left, size, r, g, b);
    });
    
    $('#message').keypress(function (e) {
        if (e.which == 13) {//Enter key pressed
            e.stopPropagation();
            $('#send').click();//Trigger search button click event
            return false;
        }
    });

    $("#send").click(function () {
        synx.sendChat($("#message").val());
        $("#message").val("");
    });
    

    $("#chat").dialog({
        autoOpen:false,
        width:500,
        height: 500
    });

    $("#openChat").click(function () {
        $("#chat").dialog("open");
    });
});